package com.Mms.untl;

import com.Mms.model.Major;
import com.Mms.model.Uinfo;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;

public class Decryption {

    private  static final List<String> Academy = Arrays.asList("电子信息学院","商学院","管理学院","人文艺术学院","国际贸易学院");

    public static Uinfo decryInfo(String sno){
      Uinfo uinfo = new Uinfo();
      uinfo.setUstuno(sno);
      String grade = "";
        String acade = "";
        String  major= "";
        String sclass = "";
        String uno = "";


      for(int i=0;i<sno.length();i++){
          if(i<4){
              grade=grade+sno.charAt(i);
          if (i==3){
              uinfo.setGrade(grade);
          }}
          if(i>3&&i<6){
              acade=acade+sno.charAt(i);
              if(acade.length()==2){
                  switch (acade) {
                      case "01":
                          uinfo.setAcademy(Academy.get(0));
                      case "02":
                          uinfo.setAcademy(Academy.get(1));
                      case "03":
                          uinfo.setAcademy(Academy.get(2));
                      case "04":
                          uinfo.setAcademy(Academy.get(3));
                      case "05":
                          uinfo.setAcademy(Academy.get(4));
                        }
              }
          }

          if(i>5&&i<8){
              major=major+sno.charAt(i);
              if(major.length()==2){
                  uinfo.setMajor(major);
              }
          }
          if(i>7&&i<10){
              sclass=sclass+sno.charAt(i);
              if(sclass.length()==2){
                  uinfo.setSclass(sclass);
              }
          }
          if (i>9&&i<=11){
              uno=uno+sno.charAt(i);
              if(uno.length()==2){
                  uinfo.setUno(uno);
              }
          }
          }



        return  uinfo;
    }
}
